package cn.ichiva.puppet.example.base.p1;

import javafx.fxml.FXML;
import javafx.fxml.impl.AbstractPuppetComponent;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;

/**
 * 表达式绑定,主意是从controller开始的
 */
public class L2BindComponent extends AbstractPuppetComponent {

    //简单数据绑定
    @FXML
    public String site = "傀儡师";
    //表达式绑定
    @FXML
    public  String url = "ichiva.cn";
    //特殊符号绑定
    @FXML
    public String alexa = "${10000+}";

    @Override
    public CharSequence render() {
        imports(VBox.class, Label.class);
        return """
                <VBox>
                    <Label text="${'site : ' + controller.site}" />
                    <Label text='#${alexa}' />
                    <Label text="${controller.details()}" />
                </VBox>
                """;
    }

    @FXML
    public String details(){
        return "http://www." + url;
    }
}
